package hys.wwsa.modules.gene.controller;

import java.util.Arrays;
import java.util.Map;

import hys.wwsa.modules.gene.entity.GenesEntity;
import hys.wwsa.modules.gene.service.GenesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import hys.wwsa.common.utils.PageUtils;
import hys.wwsa.common.utils.R;



/**
 * 
 *
 * @author hys
 * @email hys@gmail.com
 * @date 2024-02-19 16:11:06
 */
@RestController
@RequestMapping("gene/genes")
public class GenesController {
    @Autowired
    private GenesService genesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("gene:genes:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = genesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{hhlGid}")
    @RequiresPermissions("gene:genes:info")
    public R info(@PathVariable("hhlGid") String hhlGid){
		GenesEntity genes = genesService.getById(hhlGid);

        return R.ok().put("genes", genes);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("gene:genes:save")
    public R save(@RequestBody GenesEntity genes){
        genes.setHhlGid(genes.getGenes()+genes.getDiseases());
        System.out.println(genes.getDisAbbr());
        System.out.println(genes.getHhlGid());
        genesService.save(genes);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("gene:genes:update")
    public R update(@RequestBody GenesEntity genes){
		genesService.updateById(genes);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("gene:genes:delete")
    public R delete(@RequestBody String[] hhlGids){
		genesService.removeByIds(Arrays.asList(hhlGids));

        return R.ok();
    }

}
